<!DOCTYPE HTML>
<html>
<head>

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>UMEDITOR 重置编辑器</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="../themes/default/_css/umeditor.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="../third-party/jquery.min.js"></script>
    <script type="text/javascript" src="../third-party/template.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="editor_api.js"></script>
    <script type="text/javascript" src="../lang/zh-cn/zh-cn.js"></script>
    <style type="text/css">
        h1{
            font-family: "微软雅黑";
            font-weight: normal;
        }
    </style>
</head>
<body>
<h1>UMEDITOR 重置编辑器</h1>

<!--style给定宽度可以影响编辑器的最终宽度-->
<div id="container"><div class="content" id="simple" style="width:800px;height:240px;"></div></div>
<p><input type="button" onclick="simple()" value="重置编辑器内部参数"><span id="txt"></span></p>
<p><input id="destroy" type="button" onclick="destroy()" value="销毁编辑器"></p>

<script type="text/javascript">
    var um = UM.getEditor('simple');
    function simple() {
        if(um){
            um.setContent("编辑器内部变量已经被重置!");
            um.reset();
        }
    }
    function destroy(){
        um.destroy();
        um = null;
        clearInterval(timer);
        var button = document.getElementById("destroy");

        button.value = "重新渲染";
        button.onclick = function(){
            um = UM.getEditor('simple');
            this.value="销毁编辑器";
            this.onclick = destroy;
            timer = setInterval( setMsg, 100 );
        }
    }
    function setMsg() {
        if(um && um.undoManger){
            document.getElementById( "txt" ).innerHTML = "编辑器当前保存了 <span style='color: red'> " + um.undoManger.list.length + " </span>次操作";
        }
    }
    var timer = setInterval( setMsg, 100 );
</script>

</body>
</html>